/*
 * SteepTimer - A timer designed for tea fanatics
 * Copyright (C) 2011  Wesley Crossman
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <QtGui/QApplication>
#include "TeaWindow.h"
#ifdef Q_OS_WIN
#include "qt_windows.h"
#endif

int main(int argc, char *argv[]) {
#ifdef Q_OS_WIN
    //mutex just for locking installer -- not used for restricting to
    //one instance, since semaphore has a better user experience
    HANDLE mutex = CreateMutexA(NULL, TRUE, "CrossmanWesleySteepTimerMutex");
    HANDLE gmutex = CreateMutexA(NULL, TRUE, "Global\\CrossmanWesleySteepTimerMutex");
#endif
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);
    app.setApplicationName("SteepTimer");
    app.setOrganizationName("Wesley Crossman");
    app.setApplicationVersion("1.0");
    TeaWindow w;
    QObject::connect( &app, SIGNAL(commitDataRequest(QSessionManager &)),
                      &w, SLOT(commitData(QSessionManager &)),
                      Qt::DirectConnection );
    if (app.arguments().contains("/startup")) {
        w.setStartMinimized(true);
    }

    int ret = app.exec();
#ifdef Q_OS_WIN
    CloseHandle(mutex);
    CloseHandle(gmutex);
#endif
    return ret;
}
